﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace App1
{
    class King: Pieces
    {
        public override bool CheckLegalMove(int row, int col)
        {
            bool legal = false;
            //Side 1
            if (_side == 1)
            {
                if (row < 3 && (2 < col && col < 6))
                    if ((row == _row && Math.Abs(col - _col) == 1)
                        || (Math.Abs(row - _row) == 1 && col == _col))
                    {
                        if (!Board.Square[row, col].State)
                            legal = true;
                        else
                            if (Board.Square[row, col].Side != _side)
                                legal = true;
                    }
            }
            //Side 2
            if (_side == 2)
            {
                if (row > 6 && (2 < col && col < 6))
                    if ((row == _row && Math.Abs(col - _col) == 1)
                        || (Math.Abs(row - _row) == 1 && col == _col))
                    {
                        if (!Board.Square[row, col].State)
                            legal = true;
                        else
                            if (Board.Square[row, col].Side != _side)
                                legal = true;
                    }
            }
            return legal;
        }

        public override bool CheckSafeOfKing(int row, int col)
        {
            return true;
        }
    }
}
